package com.huawei.appmarket.support.imagecache.glide;

import android.content.Context;
import android.os.Build.VERSION;
import androidx.annotation.NonNull;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
import com.bumptech.glide.load.DecodeFormat;
import java.io.InputStream;
import java.util.Locale;
import o.aab;
import o.dky.h;
import o.Logger;
import o.dok;
import o.ContentManager;
import o.ere;
import o.erh;
import o.ri;
import o.uk;
import o.uu;
import o.uv;
import o.uv.c;
import o.ux;
import o.ux.e;
import o.ve;
import o.yu;
import o.zp;

public class GlideConfiguration implements yu {
    public static DecodeFormat ˎ() {
        DecodeFormat decodeFormat = DecodeFormat.PREFER_ARGB_8888;
        long ˋ = dok.ˋ(ContentManager.getInstant().getContext());
        int ceil = (int) Math.ceil(((double) ˋ) / 1.073741824E9d);
        Logger.ˎ("GlideConfiguration", "totalMemorySizeKb= " + ˋ + " totalMemorySize=" + ceil);
        if (ceil < 4) {
            decodeFormat = DecodeFormat.PREFER_RGB_565;
        }
        Logger.ˎ("GlideConfiguration", "config= " + decodeFormat);
        return decodeFormat;
    }

    private int ˊ() {
        return Math.min(8, Runtime.getRuntime().availableProcessors());
    }

    private long ॱ(ux uxVar) {
        return Math.min(VERSION.SDK_INT < 26 ? 16777216 : 33554432, (long) (((float) uxVar.ˏ()) * 1.5f));
    }

    private long ˎ(ux uxVar) {
        return Math.min(VERSION.SDK_INT < 26 ? 33554432 : 16777216, (long) (((float) uxVar.ˎ()) * 1.5f));
    }

    public void ˊ(@NonNull Context context, ri riVar) {
        ux ˊ = new e(context).ˊ();
        Logger.ˎ("GlideConfiguration", String.format(Locale.ENGLISH, "applyOptions: calc.getMemoryCacheSize:%s calc.getBitmapPoolSize:%s realMemoryCacheSize:%s realBitmapPoolSize:%s", new Object[]{Integer.valueOf(ˊ.ˏ()), Integer.valueOf(ˊ.ˎ()), Long.valueOf(ॱ(ˊ)), Long.valueOf(ˎ(ˊ))}));
        riVar.ˏ(new uu(r2));
        riVar.ˊ(uv.ˎ(ˊ(), "hw_source", c.ˋ));
        riVar.ˊ(new uk(r4));
        riVar.ˊ(zp.ॱ(ˎ()));
        riVar.ˋ(new ere(context, 52428800));
        aab.ˊ(h.ˊˊ);
    }

    public void ˎ(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
        registry.ˊ(ve.class, InputStream.class, new erh.c());
    }
}
